<html>
<head>
<title>File Source for functions.url.php</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">smt2</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
        
                                    
                                                                      		  [ <a href="../classtrees_smt2.html" class="menu">class tree: smt2</a> ]
		  [ <a href="../elementindex_smt2.html" class="menu">index: smt2</a> ]
		  	    [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
      <b>Packages:</b><br />
              <a href="../li_smt2.html">smt2</a><br />
              <a href="../li_PegasusPHP.html">PegasusPHP</a><br />
              <a href="../li_PHPMailer.html">PHPMailer</a><br />
            <br /><br />
                  
      
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file functions.url.php</h1>
<p>Documentation is available at <a href="../smt2/_functions.url.php.html">functions.url.php</a></p>
<div class="src-code">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;Makes&nbsp;an&nbsp;HTTP&nbsp;1.1&nbsp;compliant&nbsp;redirect.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*&nbsp;Absolute&nbsp;URLs&nbsp;are&nbsp;required,&nbsp;though&nbsp;all&nbsp;modern&nbsp;browsers&nbsp;support&nbsp;relative&nbsp;URLs.</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;</span><span class="src-doc-var">$path&nbsp;</span><span class="src-doc">&nbsp;where&nbsp;to&nbsp;go&nbsp;to,&nbsp;starting&nbsp;at&nbsp;server&nbsp;root&nbsp;(default:&nbsp;none)</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.url.php.html#functionurl_redirect">url_redirect</a><span class="src-sym">(</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a9"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;</span>=&nbsp;<a href="../smt2/_functions.url.php.html#functionurl_get_server">url_get_server</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a10"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a11"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$path</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-var">$url</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a12"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;check&nbsp;that&nbsp;server&nbsp;url&nbsp;is&nbsp;on&nbsp;the&nbsp;$path&nbsp;argument</span></div></li>
<li><div class="src-line"><a name="a13"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$path</span><span class="src-sym">,&nbsp;</span><span class="src-var">$url</span><span class="src-sym">)&nbsp;</span>===&nbsp;<span class="src-id">false</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$path&nbsp;</span>=&nbsp;<span class="src-var">$url</span>.<span class="src-var">$path</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a14"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a15"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">&quot;Location:&nbsp;&quot;</span>.<span class="src-var">$path</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a16"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">exit</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a18"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a19"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;URL&nbsp;of&nbsp;current&nbsp;server&nbsp;(protocol&nbsp;+&nbsp;domain).</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Full&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a22"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a23"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.url.php.html#functionurl_get_server">url_get_server</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;<span class="src-comm">//$protocol&nbsp;=&nbsp;&quot;http://&quot;;</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;&nbsp;<span class="src-var">$protocol&nbsp;</span>=&nbsp;<span class="src-str">&quot;http&quot;&nbsp;</span>.&nbsp;<span class="src-sym">((</span><span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTPS'</span><span class="src-sym">]</span><span class="src-sym">)&nbsp;</span>&amp;&amp;&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTPS'</span><span class="src-sym">]&nbsp;</span>!=&nbsp;<span class="src-str">&quot;off&quot;</span><span class="src-sym">)&nbsp;</span>?&nbsp;<span class="src-str">&quot;s&quot;&nbsp;</span>:&nbsp;<span class="src-id">null</span><span class="src-sym">)&nbsp;</span>.&nbsp;<span class="src-str">&quot;://&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a27"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a28"></a>&nbsp;&nbsp;<span class="src-var">$host&nbsp;</span>=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'HTTP_HOST'</span><span class="src-sym">]</span><span class="src-sym">;&nbsp;</span><span class="src-comm">//&nbsp;reliable&nbsp;in&nbsp;virtual&nbsp;hosts</span></div></li>
<li><div class="src-line"><a name="a29"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$host</span><span class="src-sym">))&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a30"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$host&nbsp;</span>=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'SERVER_NAME'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a31"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a32"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$protocol</span>.<span class="src-var">$host</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a34"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a36"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;full&nbsp;path&nbsp;to&nbsp;the&nbsp;current&nbsp;PHP&nbsp;file&nbsp;(protocol&nbsp;+&nbsp;domain&nbsp;+&nbsp;paths/to/file).</span></div></li>
<li><div class="src-line"><a name="a38"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">boolean&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$fullURI&nbsp;</span><span class="src-doc">&nbsp;append&nbsp;the&nbsp;query&nbsp;string,&nbsp;if&nbsp;any&nbsp;(default:&nbsp;false)</span></div></li>
<li><div class="src-line"><a name="a39"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Full&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a40"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a41"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.url.php.html#functionurl_get_current">url_get_current</a><span class="src-sym">(</span><span class="src-var">$fullURI&nbsp;</span>=&nbsp;<span class="src-id">false</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a42"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a43"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;quick&nbsp;check:</span></div></li>
<li><div class="src-line"><a name="a44"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;&nbsp;</span>=&nbsp;<a href="../smt2/_functions.url.php.html#functionurl_get_server">url_get_server</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a45"></a>&nbsp;&nbsp;<span class="src-var">$url&nbsp;</span>.=&nbsp;<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'SCRIPT_NAME'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a46"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><span class="src-var">$fullURI</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{&nbsp;</span><span class="src-var">$url&nbsp;</span>.=&nbsp;<span class="src-str">'?'</span>.<span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'QUERY_STRING'</span><span class="src-sym">]</span><span class="src-sym">;&nbsp;</span><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a48"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$url</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a49"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a50"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a51"></a><span class="src-doc">/**&nbsp;</span></div></li>
<li><div class="src-line"><a name="a52"></a><span class="src-doc">&nbsp;*&nbsp;Gets&nbsp;the&nbsp;base&nbsp;path&nbsp;of&nbsp;a&nbsp;URL.</span></div></li>
<li><div class="src-line"><a name="a53"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc">&nbsp;&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-var">$url&nbsp;</span><span class="src-doc">&nbsp;input&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a54"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc">&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Base&nbsp;URL</span></div></li>
<li><div class="src-line"><a name="a55"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a56"></a><span class="src-key">function&nbsp;</span><a href="../smt2/_functions.url.php.html#functionurl_get_base">url_get_base</a><span class="src-sym">(</span><span class="src-var">$url</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a57"></a><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a58"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;split&nbsp;url&nbsp;in&nbsp;dirs</span></div></li>
<li><div class="src-line"><a name="a59"></a>&nbsp;&nbsp;<span class="src-var">$paths&nbsp;</span>=&nbsp;<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$url</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a60"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;short&nbsp;URLs&nbsp;like&nbsp;http://server.com&nbsp;should&nbsp;be&nbsp;fixed</span></div></li>
<li><div class="src-line"><a name="a61"></a>&nbsp;&nbsp;<span class="src-key">if&nbsp;</span><span class="src-sym">(</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$paths</span><span class="src-sym">)&nbsp;</span>&gt;&nbsp;<span class="src-num">3</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a62"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;remove&nbsp;last&nbsp;element,&nbsp;so&nbsp;we&nbsp;do&nbsp;not&nbsp;have&nbsp;to&nbsp;worry&nbsp;about&nbsp;the&nbsp;query&nbsp;string&nbsp;(?var1=value1&amp;var2=value2#anchor...)</span></div></li>
<li><div class="src-line"><a name="a63"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.php.net/array_pop">array_pop</a><span class="src-sym">(</span><span class="src-var">$paths</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a64"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a65"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;and&nbsp;we&nbsp;have&nbsp;the&nbsp;BASE&nbsp;href</span></div></li>
<li><div class="src-line"><a name="a66"></a>&nbsp;&nbsp;<span class="src-var">$base&nbsp;</span>=&nbsp;<a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">,&nbsp;</span><span class="src-var">$paths</span><span class="src-sym">)&nbsp;</span>.&nbsp;<span class="src-str">&quot;/&quot;</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a67"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a68"></a>&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$base</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a69"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a70"></a><span class="src-php">?&gt;</span></div></li>
</ol>
</div>
        <div class="credit">
		    <hr />
		    Documentation generated on Thu, 30 Sep 2010 18:26:50 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.1</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>